package com.example.demospringbootfreemarker.controller;

import com.example.demospringbootfreemarker.util.FreeMakerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ke 2022/7/12.
 */
@Controller
@RequestMapping(value = "/test")
public class TestController {

    @Autowired
    FreeMakerUtils freeMakerUtils;

    @RequestMapping(value = "/test", method = {RequestMethod.GET})
    public void test(HttpServletResponse response) {
        try {
            Map<String, Object> map = new HashMap<>();
            map.put("title", "这是一张图片");
            map.put("aaa", "aaaaaaaaaaaaaaaaa");
            map.put("bbb", "bbbbbbbbbbbbbbbbb");
            map.put("ccc", "cccccccccccccccc");
            freeMakerUtils.turnImage("test.ftl", map, response, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @RequestMapping(value = "/test2", method = {RequestMethod.GET})
    public void test2(HttpServletResponse response) {
        try {
            Map<String, Object> map = new HashMap<>();
            map.put("emptyVehicleTime", "2022-06-14 15:36:07");
            map.put("fullVehicleTime", "2022-06-14 15:36:07");
            map.put("billTitle", "xxxxx");
            map.put("billNo", "111");
            map.put("merchantName", "222");
            map.put("plateCode", "333");
            map.put("productName", "444");
            map.put("loadingCount", "222");
            map.put("grossWeight", "222");
            map.put("tareWeight", "222");
            map.put("suttleWeight", "222");
            map.put("driverName", "222");
            map.put("freightPrice", "222");
            freeMakerUtils.turnImage("出库磅单.ftl", map, response, "https://wyyt-dev.oss-cn-huhehaote.aliyuncs.com/temporary/wyyt-doc/2022/07/27/files_8130065349304249268.html");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
